package easy

func FindJudge(n int, trust [][]int) int {
	inDegree := make([]int, n+1)
	outDegree := make([]int, n+1)
	for i := 0; i < len(trust); i++ {
		x := trust[i][0]
		y := trust[i][1]
		inDegree[y]++
		outDegree[x]++
	}
	for i := 1; i <= n; i++ {
		if inDegree[i] == n-1 && outDegree[i] == 0 {
			return i
		}
	}
	return -1
}
